<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <title>Table - Brand</title>
    <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
    <link rel="stylesheet" href="assets/fonts/fontawesome-all.min.css">
    <style>
        a{
            text-decoration: none;
        }
    </style>
</head>

<body id="page-top">
<div id="app">
    <div id="wrapper">
        <nav class="navbar navbar-dark align-items-start sidebar sidebar-dark accordion  p-0" style="background-color: rgb(46, 53, 97);">
            <div class="container-fluid d-flex flex-column p-0"><a class="navbar-brand d-flex justify-content-center align-items-center sidebar-brand m-0" href="#">
                <div class="sidebar-brand-icon rotate-n-15"></div>
                <div class="sidebar-brand-text mx-3"><img class="border rounded-circle img-profile" src="assets/img/avatars/avatar1.jpeg"></div>
            </a>
                <hr class="sidebar-divider my-0">
                <ul class="navbar-nav text-light" id="accordionSidebar">
                    <li class="nav-item">
                    <li class="nav-item"><a class="nav-link" href="user.html"><span style="margin-left: 50px;">用户信息管理</span></a>
                    <li class="nav-item"><a class="nav-link" href="school.html"><span style="margin-left: 50px;">院校信息管理</span></a>
                    <li class="nav-item"><a class="nav-link active" href="major.html"><span style="margin-left: 50px;">专业信息管理</span></a><a class="nav-link" href="#"><span style="margin-left: 50px;">返回用户主页</span></a>
                    <li class="nav-item"><a class="nav-link"><span style="margin-left: 60px;">退出登陆</span></a>
                </ul>

            </div>
        </nav>
        <div class="d-flex flex-column" id="content-wrapper">
            <div id="content">
                <nav class="navbar navbar-light navbar-expand bg-white shadow mb-4 topbar static-top">
                    <div class="container-fluid"><button class="btn btn-link d-md-none rounded-circle me-3" id="sidebarToggleTop" type="button"><i class="fas fa-bars"></i></button>
                        <form class="d-none d-sm-inline-block me-auto ms-md-3 my-2 my-md-0 mw-100 navbar-search">
                            <div class="input-group"><input class="bg-light form-control border-0 small" type="text" placeholder="搜索"><button class="btn btn-primary py-0" type="button"><i class="fas fa-search"></i></button></div>
                        </form>
                        <ul class="navbar-nav flex-nowrap ms-auto">
                            <li class="nav-item dropdown d-sm-none no-arrow"><a class="dropdown-toggle nav-link" aria-expanded="false" data-bs-toggle="dropdown" href="#"><i class="fas fa-search"></i></a>
                                <div class="dropdown-menu dropdown-menu-end p-3 animated--grow-in" aria-labelledby="searchDropdown">
                                    <form class="me-auto navbar-search w-100">
                                        <div class="input-group"><input class="bg-light form-control border-0 small" type="text" placeholder="Search for ...">
                                            <div class="input-group-append"><button class="btn btn-primary py-0" type="button"><i class="fas fa-search"></i></button></div>
                                        </div>
                                    </form>
                                </div>
                            </li>
                            <li class="nav-item dropdown no-arrow mx-1"></li>
                            <li class="nav-item dropdown no-arrow mx-1">
                                <div class="shadow dropdown-list dropdown-menu dropdown-menu-end" aria-labelledby="alertsDropdown"></div>
                            </li>
                            <li class="nav-item dropdown no-arrow">
                                <div class="nav-item dropdown no-arrow"><a class="dropdown-toggle nav-link" aria-expanded="false" data-bs-toggle="dropdown" href="#"><span class="d-none d-lg-inline me-2 text-gray-600 small">管理员</span></a>
                                    <div class="dropdown-menu shadow dropdown-menu-end animated--grow-in"><a class="dropdown-item" href="#"><i class="fas fa-user fa-sm fa-fw me-2 text-gray-400"></i>&nbsp;Profile</a><a class="dropdown-item" href="#"><i class="fas fa-cogs fa-sm fa-fw me-2 text-gray-400"></i>&nbsp;Settings</a><a class="dropdown-item" href="#"><i class="fas fa-list fa-sm fa-fw me-2 text-gray-400"></i>&nbsp;Activity log</a>
                                        <div class="dropdown-divider"></div><a class="dropdown-item" href="#"><i class="fas fa-sign-out-alt fa-sm fa-fw me-2 text-gray-400"></i>&nbsp;Logout</a>
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </nav>
                <div class="container-fluid">
                    <h3 class="" style="color: rgb(46, 53, 97); font-weight: bold">院校</h3>
                    <div class="card shadow">
                        <div class="card-header py-3">
                            <p class="" style="color: rgb(46, 53, 97); font-weight: bold">院校信息</p>
                        </div>
                        <div class="card-body">
                            <div class="table-responsive table mt-2" id="dataTable" role="grid" aria-describedby="dataTable_info">
                                <table class="table my-0" id="dataTable">
                                    <thead>
                                    <tr>
                                        <th style="width: 66px;padding: 8px;padding-top: 8px;padding-right: 8px;padding-bottom: 8px;padding-left: 8px;">院校ID</th>
                                        <th style="width: 189px;">院校名称</th>
                                        <th>简述</th>
                                        <th>地区</th>
                                        <th>类型</th>
                                        <th>等级</th>
                                        <th>最低分</th>
                                        <th>师资力量</th>
                                        <th style="width: 163px;">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr v-for="college in colleges" style="padding: 0px;margin: 0px;height: 41px;">
                                        <td>{{college.id}}</td>
                                        <td style="height: 41px;padding: 0px;"><img style="width: 41px;height: 41px;" :src="'../img/'+college.logo">
                                            <p class="d-inline float-end d-xxl-flex justify-content-xxl-start" style="width: 140px;height: 41px;margin: 0px;padding: 8px;">{{college.name}}</p><br>
                                        </td>
                                        <td class="text-nowrap" style="height: 41px;width: 130px;">
                                            <a href="#" data-bs-target="#modal-1" data-bs-toggle="modal" @click="findDescribes(college.id)">详情</a>
                                        </td>
                                        <td style="height: 41px;">{{college.region}}</td>
                                        <td style="height: 41px;">{{college.type}}</td>
                                        <td style="height: 41px;">{{college.level}}</td>
                                        <td style="height: 41px;">{{college.lowest}}</td>
                                        <td style="height: 41px;">
                                            <a @click="findDescribes(college.id)" href="#" data-bs-target="#modal-2" data-bs-toggle="modal">详情</a>
                                        </td>
                                        <td style="padding: 0px;margin: 0px;height: 41px;">
                                            <button class="btn btn-primary" type="button" style="width: 76.7031px;border: 0px;  height: 36px;padding: 2px;margin: 2px;border-radius: 10px;background-color: rgb(104, 185, 79);">
                                                <a :href="'school_change.html?id='+college.id" style="text-decoration: none" class="link-light">
                                                    修改
                                                </a>
                                            </button>
                                            <button @click="deleteCollege(college.id)" class="btn btn-primary" type="button" style="width: 76.7031px;
                                                height: 36px;padding: 2px;margin: 2px;border: 0px;border-radius: 10px;background-color: rgb(233, 80, 42);" data-bs-target="#modal-3" data-bs-toggle="modal">
                                                删除
                                            </button>
                                        </td>
                                    </tr>
                                    </tbody>
                                    <tfoot>
                                    <tr></tr>
                                    </tfoot>
                                </table>
                            </div>
                            <div class="row">
                                <div class="col-md-6">
                                    <nav class="float-start d-lg-flex justify-content-lg-end dataTables_paginate paging_simple_numbers">
                                        <ul class="pagination">
                                            <li class="page-item"><a class="page-link" href="javascript:;" v-if="page>1" class="page" @click="findAll(page-1)">上一页</a></li>
                                            <li class="page-item"><a class="page-link" href="javascript:;" v-if="page==1" class="page">上一页</a></li>
                                            <li  v-for="indexpage in totalPage">
                                                <span class="page-item"><a class="page-link" href="javascript:;" v-text="indexpage" @click="findAll(indexpage)"></a></span>
                                            </li>
                                            <li class="page-item"><a class="page-link" href="javascript:;" v-if="page==totalPage" class="page">下一页</a></li>
                                            <li class="page-item"><a class="page-link" href="javascript:;" v-if="page<totalPage" class="page" @click="findAll(page+1)">下一页</a></li>
                                        </ul>
                                    </nav>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <footer class="bg-white sticky-footer">
                <div class="container my-auto">
                    <div class="text-center my-auto copyright"><span>一组</span></div>
                </div>
            </footer>
        </div><a class="border rounded d-inline scroll-to-top" href="#page-top"><i class="fas fa-angle-up"></i></a>
    </div>
    <div class="modal fade" role="dialog" tabindex="-1" id="modal-1">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">概述</h4><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <p>{{this.describes}}</p>
                </div>
                <div class="modal-footer"><button class="btn btn-light" type="button" data-bs-dismiss="modal">关闭</button></div>
            </div>
        </div>
    </div>
    <div class="modal fade" role="dialog" tabindex="-1" id="modal-2">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">

                    <h4 class="modal-title">师资力量</h4><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <p>{{this.teachers}}</p>
                </div>
                <div class="modal-footer"><button class="btn btn-light" type="button" data-bs-dismiss="modal">关闭</button></div>
            </div>
        </div>
    </div>
    <script src="assets/bootstrap/js/bootstrap.min.js"></script>
    <script src="assets/js/theme.js"></script>

</div>
</body>

</html>

<script src="../js/vue.js"></script>
<script src="../js/axios.min.js"></script>
<script>
    const app = new Vue({
        el:'#app',
        data:{
            colleges:[],
            page:1,
            rows:9,
            totalPage:0,
            totals:0,
            region:"",
            type:"",
            describes:"",
            teachers:""
        },
        methods:{
            goOffline(){
                const storage = window.localStorage;
                storage.setItem("online","off");
                storage.setItem("userid",'');
                storage.setItem("role","user")
                alert("登出成功, 点击进入登陆页面")
                location.href='../login.html';
            },
            findAll(indexpage){
                if(indexpage) this.page = indexpage;
                // if(this.type==="null") this.type=null;
                // if(this.region==="null") this.region=null;
                const _this = this;
                axios.get("http://localhost:8080/colleges/findByPage?page="+this.page+"&rows="+this.rows).then((res)=>{
                    console.log(res.data)
                    _this.colleges = res.data.colleges;
                    _this.totalPage = res.data.totalPage;
                    _this.totals = res.data.totals;
                });
            },
            findDescribes(id){
                axios.get("http://localhost:8080/colleges/queryCollegeById?id="+id).then((res)=>{
                    this.describes = res.data.describes;
                    this.teachers = res.data.teachers;
                })
            },
            deleteCollege(id){
                axios.get("http://localhost:8080/colleges/deleteCollege?id="+id).then((res)=>{
                    alert("删除成功!");
                    location.reload();
                })
            }
        },
        created(){
            if(window.localStorage.getItem("online")!=="on"){
                window.location='../login.html';
            }else {
                this.findAll();
            }
        }
    })
</script>